package cn.wps.shareplay.service; import android.content.Context; import android.os.Build; import android.support.v4.app.NotificationCompat; import android.text.TextUtils; import android.util.DisplayMetrics; import cn.wps.shareplay.message.Message; import cn.wps.shareplay.message.MessageCenter; import com.iflytek.cloud.SpeechConstant; import com.iflytek.cloud.SpeechEvent; import com.iflytek.cloud.SpeechUtility; import com.iflytek.speech.VoiceWakeuperAidl; import com.mopub.common.Constants; import com.mopub.nativeads.KS2SEventNative; import defpackage.tgm; import defpackage.thm; import defpackage.tho; import defpackage.thu; import defpackage.tig; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; import java.net.URL; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.Executors; public class ShareplayManager implements tih { private final String TAG = "ShareplayManager"; tgf appType; private tig connectManager = null; private tii context = null; private volatile boolean hasCancelDownload = false; private volatile boolean hasCancelUpload = false; boolean isUpload = false; private MessageCenter messageCenter = null; private thb messageHandler = null; private thp resourceCenter = null; private tgu sender = null; private thk starWars = null; private boolean checkSharePlayUsersResponseValid(tgm tgm) { return (tgm == null || tgm.uFg == null || TextUtils.isEmpty(tgm.uFa) || tgm.uFe == null || tgm.uFg == null) ? false : true; } private boolean isLanIp(String str, String str2) { return !TextUtils.isEmpty(str) && !str.equals(str2); } private Long parseLong(String str) { try { return Long.valueOf(Long.parseLong(str)); } catch (Exception e) { return 0L; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void sendEvent(tgv tgv, int i) { Message message = new Message(); message.setAction(tgv); sendEvent(i, message); } @Override // defpackage.tih public boolean broadcastMessage(Message message) { this.messageCenter.broadCast(message); return true; } @Override // defpackage.tih public void cancelDownload() { if (this.connectManager.uIZ != null) { this.connectManager.uIZ.uIS = true; } thp thp = this.resourceCenter; thp.cancelDownload = true; if (thp.uHV != null) { thp.uHV.cPS = true; thp.uHV = null; } this.hasCancelDownload = true; } @Override // defpackage.tih public void cancelSwitchDoc(boolean z, String str, String str2, String str3) { try { thp.e(str, str2, str3, true); if (!z) { transferBroadcast(str, str2, str3); } } catch (Exception e) { e.getMessage(); } } @Override // defpackage.tih public void cancelUpload() { if (this.isUpload) { this.hasCancelUpload = true; thp thp = this.resourceCenter; if (thp.uHU != null) { tho tho = thp.uHU; tho.mIsCanceled = true; try { if (tho.uHS != null) { tho.uHS.disconnect(); tho.uHS = null; } } catch (Exception e) { } thp.uHU = null; } tig tig = thp.uHT; if (tig.uJa != null) { tig.uJa.uIF = true; } thp.cancelUpload = true; } } @Override // defpackage.tih public int checkAccessCode(String str) { try { if (this.context == null) { this.context = new tii(); } tii tii = this.context; tib.fjJ(); thr thr = new thr(); thr.lGH = "SPP/2.0"; thr.appVersion = "Android/" + tii.j(267, "9.5"); thr.packageName = (String) tii.j(268, "cn.wps.moffice_eng"); thr.accessCode = str; abmf abmf = (abmf) new abmi().a(tia.a(tib.Uq("checkaccesscode"), tib.aY(thr.lMm, "", thr.accessCode), tib.a(thr).fgY()), (abmh) null); int parseInt = Integer.parseInt(((Long) abmf.get("errorCode")).toString()); thv thv = new thv(); T t = (T) new ths(); abmf abmf2 = (abmf) abmf.get(SpeechUtility.TAG_RESOURCE_RESULT); if (abmf2 != null) { t.uId = (abmf) abmf2.get(SpeechConstant.PARAMS); } thv.result = t; thv.errorCode = parseInt; if (thv.errorCode == 0) { Map<String, String> map = thv.result.uId; String str2 = map.get("File-Passwd"); String str3 = map.get("device-id"); parseLong(map.get("File-Length")); Long valueOf = Long.valueOf(Long.parseLong(map.get("File-Length"))); this.context.i(263, map.get("File-Md5")); this.context.i(281, map.get("File-Name")); this.context.i("Custom-File-URL", map.get("Custom-File-URL")); this.context.i("File-Length", valueOf); if (!lwv.isEmpty(str3)) { this.context.i(1331, str3); } else { this.context.i(1331, ""); } if (!TextUtils.isEmpty(str2)) { this.context.i(789, str2); } else { this.context.i(789, ""); } } return thv.errorCode; } catch (Exception e) { e.printStackTrace(); return 2; } } @Override // defpackage.tih public boolean checkSpeakerIsEnableAgora(String str, String str2, String str3) { try { tgm sharePlayUserList = thp.getSharePlayUserList(str, str2, str3); if (!checkSharePlayUsersResponseValid(sharePlayUserList)) { return false; } Iterator<tgm.a> it = sharePlayUserList.uFe.iterator(); while (it.hasNext()) { tgm.a next = it.next(); if (sharePlayUserList.uFa.equals(next.userId)) { long j = next.uEY; Iterator<Long> it2 = sharePlayUserList.uFg.iterator(); while (it2.hasNext()) { if (it2.next().equals(Long.valueOf(j))) { return true; } } return false; } } return false; } catch (Exception e) { e.toString(); } } public void destory() { if (this.messageCenter != null) { this.messageCenter.destory(); this.messageCenter = null; } this.context = null; this.sender = null; this.messageHandler = null; if (this.connectManager != null) { tig tig = this.connectManager; tig.context = null; tig.uJc.clear(); this.connectManager = null; } } @Override // defpackage.tih public boolean downloadShareFile(String str, tgj tgj) { File f; if (this.hasCancelDownload) { this.resourceCenter.fjI(); return false; } try { long longValue = ((Long) this.context.j("File-Length", 0L)).longValue(); thp thp = this.resourceCenter; tii tii = this.context; if (thp.cancelDownload) { f = null; } else { String str2 = (String) tii.j("Custom-File-URL", null); if (lwv.isEmpty(str2)) { str2 = "https://" + tge.anA() + "/download?category=cloudmessage&fileId=" + str; } HttpURLConnection bq = tif.bq(str2, 30000); thp.uHV = new thm(); thp.uHV.uHP = new thm.a(tgj, longValue) { /* class defpackage.thp.AnonymousClass2 */ final /* synthetic */ tgj uHW; final /* synthetic */ long uHY; { this.uHW = r3; this.uHY = r4; } @Override // defpackage.thm.a public final void at(long j) { if (this.uHW != null) { this.uHW.onProgress(j, this.uHY); } } }; f = thp.uHV.f(bq); if (f != null && !f.exists()) { f = null; } } this.resourceCenter.fjI(); if (f != null) { this.context.i(264, f.getAbsolutePath()); sendEvent(1328, (Object) null); return true; } sendEvent(1312, (Object) null); return false; } catch (Exception e) { lve.b("ERROR", "share_play", "download failed", e); return false; } } @Override // defpackage.tih public boolean endSwitchDoc(String str, String str2, String str3) { try { return thp.e(str, str2, str3, false); } catch (Exception e) { e.printStackTrace(); return false; } } @Override // defpackage.tih public boolean gainBroadcastPermission(String str, String str2, String str3) { try { tib.fjJ(); abmf abmf = new abmf(); abmf.put("user_id", str2); abmf.put("access_code", str3); return Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(tib.Ur("/office-service/rest/cloudmessage/gainbroadcast"), tib.aY(str, str2, str3), abmf.S(abmf)), null)).get("errorCode")).toString()) == 0; } catch (Exception e) { e.printStackTrace(); return false; } } @Override // defpackage.tih public tgk getAgoraApplyInfo() { try { tii tii = this.context; HashMap hashMap = new HashMap(); hashMap.put("Cookie", "wps_sid=" + ((String) tii.j(1335, ""))); abmf abmf = (abmf) new abmi().a(tib.fjJ().uIC.w("https://zt.wps.cn/2018/meeting/activity/checkout_privilege", hashMap), (abmh) null); tgk tgk = new tgk(); tgk.result = (String) abmf.get(SpeechUtility.TAG_RESOURCE_RESULT); abmf abmf2 = (abmf) abmf.get(SpeechEvent.KEY_EVENT_RECORD_DATA); if (abmf2 != null) { long longValue = ((Long) abmf2.get("expire_time")).longValue(); long longValue2 = ((Long) abmf2.get("now")).longValue(); Object obj = abmf2.get("times"); if (obj instanceof String) { tgk.uFd = (String) obj; } else if (obj instanceof Long) { tgk.uFd = new StringBuilder().append(((Long) obj).longValue()).toString(); } tgk.gbs = longValue; tgk.uFc = longValue2; } String str = (String) abmf.get(NotificationCompat.CATEGORY_MESSAGE); if (!TextUtils.isEmpty(str)) { tgk.msg = str; } return tgk; } catch (Exception e) { return null; } } @Override // defpackage.tih public tii getContext() { return this.context; } @Override // defpackage.tih public String getFileFromMd5(String str) { return new thn().qh(str); } @Override // defpackage.tih public tgx getPushDataReceived() { return this.messageCenter; } @Override // defpackage.tih public tgl getSharePlayInfo(String str, String str2, String str3) { try { tib fjJ = tib.fjJ(); abmf abmf = (abmf) new abmi().a(fjJ.uIC.w(tib.Uq("getinfo") + "?user_id=" + str2 + "&" + "access_code=" + str3, tib.aY(str, str2, str3)), (abmh) null); if (Integer.parseInt(((Long) abmf.get("errorCode")).toString()) != 0) { return null; } abmf abmf2 = (abmf) abmf.get(SpeechUtility.TAG_RESOURCE_RESULT); tgl tgl = new tgl(); tgl.speakerId = (String) abmf2.get("speaker_user_id"); tgl.uEZ = (String) ((abmf) abmf2.get(KS2SEventNative.SCHEME_FILE)).get("file_md5"); return tgl; } catch (Exception e) { return null; } } @Override // defpackage.tih public tgm getSharePlayUserList(String str, String str2, String str3) { try { return thp.getSharePlayUserList(str, str2, str3); } catch (Exception e) { e.getMessage(); return null; } } @Override // defpackage.tih public boolean isLan() { return this.connectManager.fjM(); } @Override // defpackage.tih public boolean isNetConnected() { return this.connectManager.isNetConnected(); } /* JADX WARNING: Removed duplicated region for block: B:37:0x0222 */ @Override // defpackage.tih public int joinSharePlay(String str, String str2) { String str3; String str4; String str5; if (this.context == null) { this.context = new tii(); } try { str5 = UUID.randomUUID().toString(); } catch (Exception e) { str5 = ""; } try { tii tii = this.context; tib.fjJ(); thr thr = new thr(); thr.lGH = "SPP/2.0"; thr.lMm = (String) tii.j(1335, ""); thr.gnH = (String) tii.j(1336, ""); thr.uIb = Build.MODEL; thr.appVersion = "Android/" + tii.j(267, "9.5"); thr.packageName = (String) tii.j(268, "cn.wps.moffice_eng"); thr.uIa = (String) tii.j(269, ""); thr.accessCode = str; thr.uGJ = str5; thr.userId = str2; abmf abmf = (abmf) new abmi().a(tia.a(tib.Uq("join"), (Map<String, String>) null, tib.a(thr).fgY()), (abmh) null); int parseInt = Integer.parseInt(((Long) abmf.get("errorCode")).toString()); thv thv = new thv(); T t = (T) new ths(); abmf abmf2 = (abmf) abmf.get(SpeechUtility.TAG_RESOURCE_RESULT); if (abmf2 != null) { t.uIc = (String) abmf2.get("groupInitiatorId"); t.userId = (String) abmf2.get("userId"); t.uIf = (String) abmf2.get("broker"); t.uIe = ((Boolean) abmf2.get("privilege_rtc")).booleanValue(); abmf abmf3 = (abmf) abmf2.get("permission"); thu.a aVar = new thu.a(); aVar.uIk = ((Boolean) abmf3.get("rtc_switch")).booleanValue(); aVar.uIl = ((Boolean) abmf3.get("audience_rtc_mute")).booleanValue(); aVar.uIm = ((Boolean) abmf3.get("ink_switch")).booleanValue(); aVar.uIn = ((Boolean) abmf3.get("audience_ink_permissible")).booleanValue(); aVar.uIo = ((Boolean) abmf3.get("switch_file_switch")).booleanValue(); aVar.uIp = ((Boolean) abmf3.get("audience_switch_file_permissible")).booleanValue(); t.uIh = aVar; t.uId = (abmf) abmf2.get(SpeechConstant.PARAMS); t.uIg = (String) abmf2.get("serverVersion"); } thv.errorCode = parseInt; thv.result = t; if (thv.errorCode != 0) { return thv.errorCode; } String str6 = thv.result.userId; try { str4 = thv.result.uId.get("initiator_app_version"); } catch (Exception e2) { str4 = ""; str3 = str6; if (str3 == null) { } this.context.Us(str); this.context.Ut(str3); this.context.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str3); this.context.i(270, str4); this.messageCenter.createPrivateMessageBox(str3, str); this.messageCenter.startHeartbeat(); return 0; } try { thu.a aVar2 = thv.result.uIh; if (aVar2 != null) { boolean z = aVar2.uIk && thv.result.uIe; boolean z2 = aVar2.uIl; boolean z3 = aVar2.uIo; this.context.i(1333, Boolean.valueOf(z)); this.context.i(1332, Boolean.valueOf(z2)); this.context.i(1334, Boolean.valueOf(z3)); } String str7 = thv.result.uIf; if (!TextUtils.isEmpty(str7)) { tge.Un(str7); } str3 = str6; } catch (Exception e3) { str3 = str6; if (str3 == null) { str3 = UUID.randomUUID().toString(); } this.context.Us(str); this.context.Ut(str3); this.context.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str3); this.context.i(270, str4); this.messageCenter.createPrivateMessageBox(str3, str); this.messageCenter.startHeartbeat(); return 0; } this.context.Us(str); this.context.Ut(str3); this.context.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str3); this.context.i(270, str4); this.messageCenter.createPrivateMessageBox(str3, str); this.messageCenter.startHeartbeat(); return 0; } catch (Exception e4) { str4 = ""; str3 = null; if (str3 == null) { } this.context.Us(str); this.context.Ut(str3); this.context.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str3); this.context.i(270, str4); this.messageCenter.createPrivateMessageBox(str3, str); this.messageCenter.startHeartbeat(); return 0; } } @Override // defpackage.tih public void onHandleHeartbeatResult(tgh tgh, boolean z) { if (this.sender != null) { tgu tgu = this.sender; if (tgu.uFo != null) { tgu.uFo.handleHeartbeatResult(tgh, z); } } } @Override // defpackage.tih public void onReceived(Message message) { this.messageHandler.d(message); } @Override // defpackage.tih public void quitSharePlay(final String str, final boolean z) { final String userId = this.context.getUserId(); final String accessCode = this.context.getAccessCode(); new Thread(new Runnable() { /* class cn.wps.shareplay.service.ShareplayManager.AnonymousClass2 */ public final void run() { try { if (!TextUtils.isEmpty(userId) && z) { thp unused = ShareplayManager.this.resourceCenter; String str = str; String str2 = userId; String str3 = accessCode; tib fjJ = tib.fjJ(); tib.Uo(fjJ.uIC.w(tib.Uq("quitAnonymous") + "?joinner=" + str2, tib.aY(str, str2, str3))); } } catch (Exception e) { e.printStackTrace(); } } }).start(); tig tig = this.connectManager; if (tig.uJa != null) { tig.uJa.uIF = true; tig.uJa.close(); } tig.uJa = null; if (tig.uJb != null) { tig.uJb.uIF = true; tig.uJb.close(); } tig.uJb = null; tii tii = this.context; tii.aL(257); tii.aL(1030); tii.aL(256); tii.aL(260); tii.aL(262); tii.aL(264); tii.aL(263); tii.aL(1028); tii.aL(280); tii.aL(277); tii.aL(789); tii.aL(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED)); tii.aL(1330); tii.aL(266); tii.aL(1331); tii.aL(270); tii.aL(271); tii.aL(1332); tii.aL(1333); tii.aL(1335); tii.aL(1334); this.connectManager.fjN(); this.messageCenter.stopHeartbeat(); } @Override // defpackage.tih public int reJoinSharePlay(String str, String str2, String str3) { if (this.context == null) { this.context = new tii(); } this.context.Us(str2); this.context.Ut(str2); this.context.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str3); this.context.Uu(str); this.messageCenter.createPrivateMessageBox(str2, str2); this.messageCenter.startHeartbeat(); return 0; } @Override // defpackage.tih public void regeditEventHandle(String str, tgr tgr, tgf tgf, boolean z) { this.sender = new tgu(tgr); this.messageHandler = new thb(this.sender, this); this.appType = tgf; if (tgf == tgf.PRESENTATION) { thb thb = this.messageHandler; tgz tgz = new tgz(this.sender); thb.a(tgv.JUMP_NEXT_PAGE, tgz); thb.a(tgv.JUMP_PREV_PAGE, tgz); thb.a(tgv.JUMP_SPECIFIED_PAGE, tgz); thb.a(tgv.SHOW_END_PAGE, tgz); thb.a(tgv.CANCLE_END_PAGE, tgz); thb.a(tgv.LASER_PEN_MSG, tgz); thb.a(tgv.SHARE_PLAY_INK_MSG, tgz); thb.a(tgv.SHARE_PLAY_INK_UNDO, tgz); thb.a(tgv.SHARE_PLAY_INK_DISAPPEAR, tgz); thb.a(tgv.SHARE_PLAY_REQUEST_INK_HISTORY, tgz); thb.a(tgv.EXE_NEXT_ANIMATION, tgz); thb.a(tgv.PAUSE_PLAY, tgz); thb.a(tgv.RESUME_PLAY, tgz); thb.a(tgv.START_PLAY, tgz); thb.a(tgv.EXIT_APP, tgz); thb.a(tgv.CANCEL_DOWNLOAD, tgz); thb.a(tgv.NOTIFY_UPLOAD, tgz); thb.a(tgv.NOTIFY_NO_NEED_UPLOAD, tgz); thb.a(tgv.REQUEST_PAGE, tgz); thb.a(tgv.PPT_SCALE_AND_SLIDE_PAGE, tgz); thb.a(tgv.VIDEO_AUDIO_ACTION, tgz); } else if (tgf == tgf.PUBLIC) { thb thb2 = this.messageHandler; tgz tgz2 = new tgz(this.sender); thb2.a(tgv.INVITE_TV_JOIN, tgz2); thb2.a(tgv.TRANSFER_FILE, tgz2); thb2.a(tgv.CANCEL_UPLOAD, tgz2); } else if (tgf == tgf.SPREADSHEET) { thb thb3 = this.messageHandler; tgz tgz3 = new tgz(this.sender); thb3.a(tgv.EXE_NEXT_ANIMATION, tgz3); thb3.a(tgv.PAUSE_PLAY, tgz3); thb3.a(tgv.RESUME_PLAY, tgz3); thb3.a(tgv.START_PLAY2, tgz3); thb3.a(tgv.SS_SELECTION, tgz3); thb3.a(tgv.SS_SELECTSHEET, tgz3); thb3.a(tgv.SS_CLIENTDATA, tgz3); thb3.a(tgv.EXIT_APP, tgz3); thb3.a(tgv.CANCEL_DOWNLOAD, tgz3); thb3.a(tgv.CANCEL_UPLOAD, tgz3); thb3.a(tgv.NOTIFY_UPLOAD, tgz3); thb3.a(tgv.NOTIFY_NO_NEED_UPLOAD, tgz3); thb3.a(tgv.REQUEST_PAGE, tgz3); } else if (tgf == tgf.WRITER) { thb thb4 = this.messageHandler; tgz tgz4 = new tgz(this.sender); thb4.a(tgv.EXIT_APP, tgz4); thb4.a(tgv.PAUSE_PLAY, tgz4); thb4.a(tgv.RESUME_PLAY, tgz4); thb4.a(tgv.WRITER_SCROLL_PAGE, tgz4); thb4.a(tgv.WRITER_SCALE_PAGE, tgz4); thb4.a(tgv.WRITER_RECONNECT, tgz4); thb4.a(tgv.WRITER_LASER_PEN, tgz4); thb4.a(tgv.HAS_SCROLL_TO_HEAD, tgz4); thb4.a(tgv.HAS_SCROLL_TO_TAIL, tgz4); thb4.a(tgv.CANCEL_DOWNLOAD, tgz4); thb4.a(tgv.NOTIFY_UPLOAD, tgz4); thb4.a(tgv.NOTIFY_NO_NEED_UPLOAD, tgz4); } else if (tgf == tgf.PDF) { thb thb5 = this.messageHandler; tgu tgu = this.sender; Iterator<tgv> it = tgw.fjC().crl().iterator(); while (it.hasNext()) { thb5.a(it.next(), new tgz(tgu)); } } else if (tgf == tgf.PC_PPT) { thb thb6 = this.messageHandler; tgz tgz5 = new tgz(this.sender); thb6.a(tgv.EXIT_APP, tgz5); thb6.a(tgv.PAGE_COUNT, tgz5); thb6.a(tgv.PAUSE_PLAY, tgz5); thb6.a(tgv.START_PLAY, tgz5); thb6.a(tgv.CURRENT_PAGE, tgz5); } this.connectManager = new tig(this.context); this.messageCenter = new MessageCenter(str, this, this.connectManager, z); this.resourceCenter = new thp(this.connectManager); } @Override // defpackage.tih public thk registerArtemisPush() { if (this.starWars == null) { this.starWars = new thj(); this.messageCenter.setStarWars(this.starWars); } return this.starWars; } public boolean reportJoinAgoraChannel(String str, String str2, String str3, int i) { try { tib.fjJ(); abmf abmf = new abmf(); abmf.put("user_id", str2); abmf.put("access_code", str3); abmf.put("agora_user_id", Integer.valueOf(i)); return Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(tib.Ur("/agora/channel/join"), tib.aY(str, str2, str3), abmf.S(abmf)), null)).get("errorCode")).toString()) == 0; } catch (Exception e) { return false; } } public boolean reportLeaveAgoraChannel(String str, String str2, String str3) { try { tib.fjJ(); abmf abmf = new abmf(); abmf.put("user_id", str2); abmf.put("access_code", str3); return Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(tib.Ur("/agora/channel/leave"), tib.aY(str, str2, str3), abmf.S(abmf)), null)).get("errorCode")).toString()) == 0; } catch (Exception e) { return false; } } @Override // defpackage.tih public tgg requestAgoraChannel(String str, String str2, String str3, String str4) { thv thv; try { tib.fjJ(); abmf abmf = new abmf(); abmf.put("app_id", str); abmf.put("user_id", str3); abmf.put("access_code", str4); abmf abmf2 = (abmf) new abmi().a(tia.a(tib.Ur("/agora/channel/token"), tib.aY(str2, str3, str4), abmf.S(abmf)), (abmh) null); int parseInt = Integer.parseInt(((Long) abmf2.get("errorCode")).toString()); if (parseInt != 0) { thv = null; } else { T t = (T) new tgg(); abmf abmf3 = (abmf) abmf2.get(SpeechUtility.TAG_RESOURCE_RESULT); t.name = (String) abmf3.get("channel_name"); t.uEV = ((Long) abmf3.get("limit_user_count")).longValue(); t.uEW = ((Long) abmf3.get("current_user_count")).longValue(); t.token = (String) abmf3.get("token"); t.uEY = ((Long) abmf3.get("agora_user_id")).longValue(); thv = new thv(); thv.errorCode = parseInt; thv.result = t; } if (thv == null) { return null; } return thv.result; } catch (SocketTimeoutException e) { tgg tgg = new tgg(); tgg.uEX = true; return tgg; } catch (Exception e2) { return null; } } @Override // defpackage.tih public void reset() { this.hasCancelDownload = false; this.resourceCenter.fjI(); } @Override // defpackage.tih public void sendEvent(int i, Object obj) { tgt tgt = new tgt(); tgt.type = i; tgt.data = obj; this.sender.a(tgt); } @Override // defpackage.tih public boolean sendMessage(Message message, String str) { this.messageCenter.send(message, str); return true; } @Override // defpackage.tih public void setConnectHandler(tgi tgi) { tig tig = this.connectManager; tig.uJc.clear(); if (tgi != null) { tig.uJc.add(tgi); } } @Override // defpackage.tih public void setContext(tii tii) { this.context = tii; } @Override // defpackage.tih public void setOpenPassword(String str, String str2, String str3, String str4) { if (this.context != null) { this.context.i(789, str4); } try { tht tht = new tht(); HashMap hashMap = new HashMap(); hashMap.put("File-Passwd", str4); tht.uId = hashMap; tib.fjJ(); abmf a = tib.a(tht); StringBuilder sb = new StringBuilder(); sb.append(tib.Uq("updatepass")); sb.append("?accesscode=").append(str3); if (Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(sb.toString(), tib.aY(str, str2, str3), a.fgY()), (abmh) null)).get("errorCode")).toString()) == 0) { } } catch (Exception e) { e.printStackTrace(); } } public void startFileServer(tij tij) { tig tig = this.connectManager; if (tig.uIZ != null) { tig.uIZ.uIT = tij; } else { tig.uIZ = new tid(); tig.uIZ.uIT = tij; tid tid = tig.uIZ; if (tid.uIO == null) { tid.uIO = Executors.newFixedThreadPool(1); } tid.uIO.submit(new Runnable() { /* class defpackage.tid.AnonymousClass1 */ public final void run() { Socket socket = null; try { tid tid = tid.this; if (tid.ahR(8888)) { tid.uIP = new ServerSocket(8889); } else { tid.uIP = new ServerSocket(8888); } while (true) { try { socket = tid.uIP.accept(); socket.setSoTimeout(5000); new Thread(new Runnable(socket) { /* class defpackage.tid.AnonymousClass3 */ final /* synthetic */ Socket uIV; { this.uIV = r2; } public final void run() { int i; try { InputStream inputStream = this.uIV.getInputStream(); ByteBuffer allocate = ByteBuffer.allocate(8); while (tid.this.d(inputStream, allocate.array()) && (i = allocate.getInt()) > 0 && i < Integer.MAX_VALUE) { EnumC0296tgy ahO = EnumC0296tgy.ahO(allocate.getInt()); if (ahO != null) { if (ahO != EnumC0296tgy.HEARTBEAT) { byte[] bArr = new byte[(i - 8)]; if (!tid.this.d(inputStream, bArr) || tid.this.uIS) { break; } if (ahO == EnumC0296tgy.ULOADFILE && tid.this.a(bArr, tid.this.uIT) != null) { OutputStream outputStream = this.uIV.getOutputStream(); allocate.position(4); allocate.putInt(1); outputStream.write(allocate.array()); } allocate = ByteBuffer.allocate(8); } else { this.uIV.getOutputStream().write(allocate.array()); allocate = ByteBuffer.allocate(8); } } else { allocate = ByteBuffer.allocate(8); } } tid.this.uIS = false; this.uIV.close(); } catch (Exception e) { try { this.uIV.close(); } catch (IOException e2) { e2.printStackTrace(); } } } }).start(); } catch (Exception e) { if (socket != null) { socket.close(); } if (tid.uIT != null) { tgf tgf = tgf.PUBLIC; } try { tid.a(tid.this, tid.this.uIP); tid.this.uIP = null; return; } catch (Exception e2) { e2.printStackTrace(); return; } } } } catch (Exception e3) { e3.printStackTrace(); try { tid.a(tid.this, tid.this.uIP); tid.this.uIP = null; } catch (Exception e4) { e4.printStackTrace(); } } catch (Throwable th) { try { tid.a(tid.this, tid.this.uIP); tid.this.uIP = null; } catch (Exception e5) { e5.printStackTrace(); } throw th; } } }); if (tid.uIQ == null) { tid.uIQ = Executors.newFixedThreadPool(1); } tid.uIQ.submit(new Runnable() { /* class defpackage.tid.AnonymousClass2 */ public final void run() { try { tid tid = tid.this; if (tid.ahR(9888)) { tid.uIR = new ServerSocket(9889); } else { tid.uIR = new ServerSocket(9888); } Socket socket = null; while (true) { try { socket = tid.uIR.accept(); socket.setSoTimeout(5000); new Thread(new Runnable(socket) { /* class defpackage.tid.AnonymousClass4 */ final /* synthetic */ Socket uIV; { this.uIV = r2; } public final void run() { int i; try { InputStream inputStream = this.uIV.getInputStream(); ByteBuffer allocate = ByteBuffer.allocate(8); while (tid.this.d(inputStream, allocate.array()) && (i = allocate.getInt()) > 0 && i < Integer.MAX_VALUE) { EnumC0296tgy ahO = EnumC0296tgy.ahO(allocate.getInt()); if (ahO != null) { if (ahO != EnumC0296tgy.HEARTBEAT) { if (!tid.this.d(inputStream, new byte[(i - 8)]) || tid.this.uIS) { break; } EnumC0296tgy tgy = EnumC0296tgy.PPTMESSAGE; allocate = ByteBuffer.allocate(8); } else { this.uIV.getOutputStream().write(allocate.array()); allocate = ByteBuffer.allocate(8); } } else { allocate = ByteBuffer.allocate(8); } } tid.this.uIS = false; this.uIV.close(); lve.aj("INFO", "project", "accept success"); } catch (Exception e) { try { this.uIV.close(); } catch (IOException e2) { e2.printStackTrace(); } lve.aj("INFO", "project", "server read exception: " + e.toString()); } try { this.uIV.close(); } catch (IOException e3) { e3.printStackTrace(); lve.aj("ERROR", "project", "server close exception: " + e3.toString()); } } }).start(); } catch (Exception e) { lve.aj("ERROR", "project", "server exception: " + e.toString()); if (socket != null) { socket.close(); } if (tid.uIT != null) { tgf tgf = tgf.PUBLIC; } return; } } } catch (Exception e2) { e2.printStackTrace(); } finally { tid.a(tid.this, tid.this.uIR); tid.this.uIR = null; } } }); } tig tig2 = this.connectManager; tig2.cPt = false; if (tig2.uJd == null) { tig2.uJd = new tig.a(1000); tig2.uJd.start(); } tig2.fjQ(); } @Override // defpackage.tih public boolean startSharePlayService(int i) { boolean z; thv thv; this.hasCancelUpload = false; this.isUpload = false; try { tii tii = this.context; tht tht = new tht(); tht.uIi = true; tht.uIj = 100; tht.lGH = "SPP/2.0"; tht.appVersion = "Android/" + tii.j(267, "9.5"); tht.packageName = (String) tii.j(268, "cn.wps.moffice_eng"); tht.uIa = (String) tii.j(269, ""); tht.lMm = (String) tii.j(1335, ""); tht.gnH = (String) tii.j(1336, ""); tht.uIb = Build.MODEL; HashMap hashMap = new HashMap(); File file = new File((String) tii.j(264, "")); if (!file.exists()) { z = false; } else { hashMap.put("File-Passwd", (String) tii.j(789, "")); String aG = tie.aG(file); hashMap.put("File-Md5", aG); hashMap.put("File-Length", Long.toString(file.length())); String name = file.getName(); hashMap.put("File-Name", System.currentTimeMillis() + "|" + name + name.substring(name.lastIndexOf(".")).toLowerCase()); hashMap.put("shareplaytype", new StringBuilder().append(i).toString()); hashMap.put("device-id", (String) tii.j(1331, "")); hashMap.put("Custom-File-URL", (String) tii.j(271, "")); DisplayMetrics displayMetrics = ((Context) tii.j(1329, null)).getResources().getDisplayMetrics(); hashMap.put("display", "w:" + displayMetrics.widthPixels + ";h:" + displayMetrics.heightPixels + ";dpi:" + displayMetrics.densityDpi + ";ydpi:" + displayMetrics.ydpi); tht.uId = hashMap; tib.fjJ(); abmf abmf = (abmf) new abmi().a(tia.a(tib.Uq("launch"), (Map<String, String>) null, tib.a(tht).fgY()), (abmh) null); int parseInt = Integer.parseInt(((Long) abmf.get("errorCode")).toString()); if (parseInt != 0) { thv = null; } else { T t = (T) new thu(); abmf abmf2 = (abmf) abmf.get(SpeechUtility.TAG_RESOURCE_RESULT); t.accessCode = (String) abmf2.get("accessCode"); t.fileId = (String) abmf2.get("fileId"); t.uHZ = (String) abmf2.get("sessionId"); t.userId = (String) abmf2.get("userId"); t.uIf = (String) abmf2.get("broker"); t.uIe = ((Boolean) abmf2.get("privilege_rtc")).booleanValue(); abmf abmf3 = (abmf) abmf2.get("permission"); if (abmf3 != null) { thu.a aVar = new thu.a(); aVar.uIk = ((Boolean) abmf3.get("rtc_switch")).booleanValue(); aVar.uIl = ((Boolean) abmf3.get("audience_rtc_mute")).booleanValue(); aVar.uIm = ((Boolean) abmf3.get("ink_switch")).booleanValue(); aVar.uIn = ((Boolean) abmf3.get("audience_ink_permissible")).booleanValue(); aVar.uIo = ((Boolean) abmf3.get("switch_file_switch")).booleanValue(); aVar.uIp = ((Boolean) abmf3.get("audience_switch_file_permissible")).booleanValue(); t.uIh = aVar; } thv thv2 = new thv(); thv2.errorCode = parseInt; thv2.result = t; thv = thv2; } if (thv.errorCode != 0) { z = false; } else { String str = thv.result.accessCode; String str2 = thv.result.userId; String str3 = thv.result.uIf; tii.Us(str); tii.Ut(str); tii.i(Integer.valueOf((int) VoiceWakeuperAidl.RES_SPECIFIED), str2); tii.i(263, aG); if (!TextUtils.isEmpty(str3)) { tge.Un(str3); } thu.a aVar2 = thv.result.uIh; if (aVar2 != null) { boolean z2 = aVar2.uIk && thv.result.uIe; boolean z3 = aVar2.uIl; boolean z4 = aVar2.uIo; tii.i(1333, Boolean.valueOf(z2)); tii.i(1332, Boolean.valueOf(z3)); tii.i(1334, Boolean.valueOf(z4)); } tii.i(266, thv.result.uHZ); z = true; } } } catch (Exception e) { e.printStackTrace(); z = false; } if (!z) { return false; } if (this.connectManager.fjP()) { this.connectManager.uJb = tig.br((String) this.context.j(277, ""), 9888); this.messageCenter.startHeartbeat(); } this.messageCenter.createPrivateMessageBox(this.context.getAccessCode(), this.context.getAccessCode()); return true; } @Override // defpackage.tih public tgp startSwitchDoc(String str, String str2, String str3, String str4, String str5) { try { this.hasCancelUpload = false; reset(); File file = new File(str5); if (!file.exists()) { return null; } String name = file.getName(); String lowerCase = name.substring(name.lastIndexOf(".")).toLowerCase(); thx thx = new thx(); thx.accessCode = str3; thx.lMm = str; thx.userId = str2; thx.fileName = System.currentTimeMillis() + "|" + name + lowerCase; thx.eeu = str4; thx.fileMd5 = tie.aG(file); thx.uIu = (int) file.length(); tib.fjJ(); tgp tgp = new tgp(); String Ur = tib.Ur("/office-service/rest/cloudmessage/startswitchfile"); Map<String, String> aY = tib.aY(thx.lMm, thx.userId, thx.accessCode); abmf abmf = new abmf(); abmf.put("access_code", thx.accessCode); abmf.put("user_id", thx.userId); abmf abmf2 = new abmf(); abmf2.put("file_name", thx.fileName); abmf2.put("file_md5", thx.fileMd5); abmf2.put("file_length", Integer.valueOf(thx.uIu)); abmf2.put("file_password", thx.uIv); abmf2.put("file_download_url", thx.eeu); abmf2.put("file_encrypt_key", thx.uIw); abmf.put("file_info", abmf2); tgp.dDc = Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(Ur, aY, abmf.fgY()), null)).get("errorCode")).toString()) == 0; tgp.uEZ = thx.fileMd5; return tgp; } catch (Exception e) { e.getMessage(); return null; } } public void stopFileServer() { tig tig = this.connectManager; if (tig.uIZ != null) { tid tid = tig.uIZ; if (tid.uIP != null) { try { tid.uIP.close(); tid.uIP = null; } catch (IOException e) { e.printStackTrace(); } } if (tid.uIR != null) { try { tid.uIR.close(); tid.uIR = null; } catch (IOException e2) { e2.printStackTrace(); } } } tig.uIZ = null; this.connectManager.fjN(); } public boolean syncsendmsg(byte[] bArr) { return this.connectManager.syncsendmsg(bArr); } @Override // defpackage.tih public boolean transferBroadcast(String str, String str2, String str3) { try { tib.fjJ(); abmf abmf = new abmf(); abmf.put("user_id", str2); abmf.put("access_code", str3); return Integer.parseInt(((Long) ((abmf) new abmi().a(tia.a(tib.Ur("/office-service/rest/cloudmessage/transferbroadcast"), tib.aY(str, str2, str3), abmf.S(abmf)), null)).get("errorCode")).toString()) == 0; } catch (Exception e) { e.printStackTrace(); return false; } } @Override // defpackage.tih public void turnOverBroadcastPermission(String str, String str2) { this.messageCenter.createPrivateMessageBox(str, str2); } @Override // defpackage.tih public void unregisteringArtemisPush() { if (this.starWars != null) { this.starWars.destory(); this.starWars = null; } } @Override // defpackage.tih public int upload(String str, tgj tgj, String str2) { int i; boolean z; boolean a; this.isUpload = true; int i2 = -1; boolean z2 = false; String str3 = (String) this.context.j(277, ""); try { if (this.connectManager.fjM() && this.connectManager.fjP() && isLanIp(str3, str2)) { tig tig = this.connectManager; AnonymousClass1 r2 = new thy() { /* class cn.wps.shareplay.service.ShareplayManager.AnonymousClass1 */ @Override // defpackage.thy public final void ahP(int i) { if (i == -1) { ShareplayManager.this.sendEvent((ShareplayManager) tgv.CANCEL_UPLOAD, (tgv) 1026); } else if (i == 1) { ShareplayManager.this.sendEvent((ShareplayManager) tgv.START_PLAY, (tgv) 1026); } } }; tig.uJa = tig.br(str3, 8888); if (tig.uJa == null) { z2 = false; } else { tig.uJa.uIJ = r2; z2 = true; } if (z2) { lve.aj("ERROR", "share_play", "upload lan"); thp thp = this.resourceCenter; tii tii = this.context; int i3 = this.appType.value; if (thp.cancelUpload) { thp.cancelUpload = false; a = false; } else { if (tgj != null) { tgj.setOnLanProgress(); } String str4 = (String) tii.j(264, ""); String str5 = (String) tii.j(789, ""); tig tig2 = thp.uHT; a = tig2.uJa == null ? false : tig2.uJa.a(str4, tii.getAccessCode(), str5, i3, tgj); } z2 = a; } } if (z2) { i = 0; i2 = i; z = z2; } else if (!this.hasCancelUpload) { lve.aj("ERROR", "share_play", "upload net"); thp thp2 = this.resourceCenter; tii tii2 = this.context; if (thp2.cancelUpload) { thp2.cancelUpload = false; z = false; } else { if (tgj != null) { tgj.setOnNetProgress(); } File file = new File((String) tii2.j(264, "")); String aG = tie.aG(file); StringBuilder sb = new StringBuilder(); sb.append("/upload?category=cloudmessage&accesscode=").append(tii2.getAccessCode()).append("&fileId=").append(aG).append("&fileSize=").append(file.length()); URL url = new URL(Constants.HTTPS, tge.anA(), sb.toString()); HttpURLConnection bq = tif.bq(url.toString(), 30000); if (bq.getResponseCode() == 202) { bq.disconnect(); HttpURLConnection bq2 = tif.bq(url.toString(), 30000); thp2.uHU = new tho(); thp2.uHU.uHR = new tho.a(tgj) { /* class defpackage.thp.AnonymousClass1 */ final /* synthetic */ tgj uHW; { this.uHW = r2; } @Override // defpackage.tho.a public final void onProgress(long j, long j2) { if (this.uHW != null) { this.uHW.onProgress(j2, j); } } }; z = !TextUtils.isEmpty(thp2.uHU.b(bq2, file)); } else { if (tgj != null) { tgj.setOnLocalProgress(); } z = true; } } } else { i = -1; i2 = i; z = z2; } this.resourceCenter.fjI(); this.isUpload = false; if (!z) { if (!this.hasCancelUpload) { sendEvent(tgv.NOTIFY_NET_ERROR, 1026); } return -1; } else if (i2 == -1) { return 1; } else { return i2; } } catch (Exception e) { lve.b("ERROR", "share_play", "upload failed", e); if (!this.hasCancelUpload) { sendEvent(tgv.NOTIFY_NET_ERROR, 1026); } this.isUpload = false; this.resourceCenter.fjI(); return -1; } } }